$(function() {
	$('#form').validate({
		rules:{
			account: {
				required:true,
				pattern: /^[0-9a-zA-Z]{6,18}$/,
				remote: {
					url: 'exist',
					type: 'get'
				}
			},
			pwd: {
				required:true,
				pattern: /^[\S]{6,18}$/
			},
			telphone: {
				required:true,
				pattern: /^1[3|4|5|6|7|8|9]\d{9}$/
			},
			remark: {
				maxlength: 255
			}
		},
		messages:{
			account:{
				required:'请输入账号',
				pattern: '6至18位数字或字母或者之间组合',
				remote: '账号已经存在'
			},
			pwd: {
				required: '请输入密码',
				pattern: '6至18位字符'
			},
			telphone: {
				required: '请输入手机号',
				pattern: '请输入合法手机号'
			},
			remark: {
				maxlength:'最多输入255个字'
			}
		},
        submitHandler:function(form){ 	
            save();
        	return false;
        }
	});
	
	//保存
	function save() {
		var json = $('#form').serializeJson();
		$.loadReq({
			type:'post',
			url:'save',
			data:json,
			success: function(res) {
				if(res.status == 'true') {
					
				} else {
					layer.alert(res.msg);
				}
			}
		});
	}
	
	$('.b-btn-save').click(function() {
		$('form').submit();
	});
});